/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DAO.UTIL.MySqlDataAccessHelper;
import POJO.DanhMuc;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.spi.DirStateFactory;

/**
 *
 * @author Oho
 */
public class DAODanhMuc {
    public static  ArrayList<DanhMuc> layDanhSachDanhMuc()
    {
        ArrayList<DanhMuc> ds = new ArrayList<DanhMuc>();
        try {
            
            MySqlDataAccessHelper help  = new MySqlDataAccessHelper();
            help.open();
            
            String str = "Select * from danhmuc";
            ResultSet rs = help.executeQuery(str);
            while(rs.next())
            {
                try {
                    DanhMuc dm  = new DanhMuc() ;
                    
                    dm.setTenDanhMuc(rs.getString("Tendanhmuc"));;
                    ds.add(dm);
                            
                } catch (SQLException ex) {
                    Logger.getLogger(DAODanhMuc.class.getName()).log(Level.SEVERE, null, ex);
                }
                
            }
                    
            help.close();
            
        } catch (SQLException ex) {
            Logger.getLogger(DAODanhMuc.class.getName()).log(Level.SEVERE, null, ex);
        }
     return ds;   
    }
}
